<%@ page language="java" import="java.util.*,com.pzhu.pojo.Book" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'show books.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
  <br/><br/>
    <h3>书籍列表</h3>
    <table border="1px">
    	<tr>
    		<th>编号</th>
    		<th>书名</th>
    		<th>价格（元）</th>
    		<th>作者</th>
    		<th>出版社</th>
    	</tr>
    	<%
    	List<Book> list=(List<Book>)request.getAttribute("list");
    	for(int i=0;i<list.size();i++){
    		if(i%2==0){
           %>
           <tr style="background-color:gray">
    		<%}else{ %>
    		<tr style="background-color:orange">
    		<%} %>
    	<td><%=list.get(i).getId()%></td>
    	<td><%=list.get(i).getName()%></td>
    	<td><%=list.get(i).getPrice()%></td>
    	<td><%=list.get(i).getAuthor()%></td>
    	<td><%=list.get(i).getPublisher()%></td>
    </tr>
    <%
    } 
    %>
    </table>
   	<br/><br/>
   	
    <h3>书籍列表</h3>
    <table border="1px">
    	<tr>
    		<th>编号</th>
    		<th>书名</th>
    		<th>价格（元）</th>
    		<th>作者</th>
    		<th>出版社</th>
    	</tr>
    	<c:forEach items="${list }" var="list" varStatus="vs">
		<c:choose>
		<c:when test="${vs.index%2==0 }"> <tr style="background-color:gray"></c:when>
		<c:otherwise> <tr style="background-color:yellow"></c:otherwise>
		</c:choose>
 
    	<td>${list.id }</td>
    	<td>${list.name }</td>
    	<td>${list.price }</td>
    	<td>${list.author }</td>
    	<td>${list.publisher }</td>
    </tr>
        </c:forEach>
    </table>
    <br/><br/><br/><br/>
    <a href="addbook.jsp">新增书目</a>
  </body>
</html>
